<?php
include_once "conn.php";
$echarts = [];
$sql = $db -> query("SELECT user_name,SUM(goods_price*order_num) AS amount FROM user JOIN order_user ON user.user_id = order_user.`user_id`
	JOIN order_goods ON order_goods.`order_user_id` = order_user.`order_user_id` 
	JOIN goods ON goods.goods_id = order_goods.`goods_id` GROUP BY user_name ORDER BY amount DESC LIMIT 0,7"); //排名前七的用户
while($row = $sql -> fetch_assoc()){
    array_push($echarts,$row);
}
echo json_encode($echarts);
$db -> close();
?>